// 封装一个 Canvas 用来被其他类实例化
class CanvasElement {
  constructor(size, style) {
    this.cv = null
    this.ctx = null

    this.init(size, style)
  }

  init(size, style) {
    const canvas = document.createElement('canvas')
    const context = canvas.getContext('2d')

    canvas.height = size.height
    canvas.width = size.width

    this.cv = canvas
    this.ctx = context
  }
}

const createCanvas = (size, style) => new Canvas(size, style)

export default createCanvas
